#include "mainwindow.h"
#include "ui_mainwindow.h"
//
#include <QDir>
#include <QMessageBox>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    //
    edit=new QLineEdit(this);
    edit->setText("C://test");
    //
    button=new QPushButton(this);
    button->setGeometry(QRect(280,50,80,25));
    //
    button->setText("创建");
    connect(button,SIGNAL(clicked(bool)),this,SLOT(createFolder()));
}

MainWindow::~MainWindow()
{
    delete ui;
}
void MainWindow::createFolder()
{
    QDir * folder=new QDir();
    bool exist=folder->exists(edit->text());
    if(exist)
    {
        QMessageBox::warning(this,tr("Create dir"),tr("文件夹已存在!"));
    }
    else
    {
        bool ok=folder->mkdir(edit->text());
        if(ok)
        {
            QMessageBox::warning(this,tr("Create Dir"),tr("文件夹创建成功！"));
        }else
        {
            QMessageBox::warning(this,tr("Create Dir"),tr("创建文件夹失败！"));
        }
    }
}
